package com.example.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @program: zhugelongchen
 * @description:
 * @author: 诸葛龙辰
 * @create: 2022-11-13 19:49
 **/
@Component
@Aspect
public class TransactionAop {
    @Pointcut("execution(* com.example.impl.*.*(..))")
    public void transationAdvice(){
    };

    @Around("transationAdvice()")
    public void around(ProceedingJoinPoint joinPoint){
        System.out.println("环绕通知前");
        try {
            joinPoint.proceed();//回调连接点方法
            System.out.println("环绕方法执行完毕");
        } catch (Throwable throwable) {
            System.out.println("环绕通知-异常");
        }finally {
            System.out.println("环绕通知-执行最终");
        }
    }

}
